package controller;

import bean.Users;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.UserService;
import util.JwtToken;
import util.ResponseBean;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {

    @Resource
    private ResponseBean responseBean;

    @Resource
    private UserService service;

    @GetMapping("personal")
    @ResponseBody
    public ResponseBean personal(HttpServletRequest request){
        String token = request.getHeader("Token");
        System.out.println("asdads");
        System.out.println(token);
        Users users=service.SelectById(token);
        if (users!=null){
            responseBean.setAll(200,"OK,this is user",users);
            return responseBean;
        }else {
            responseBean.setAll(403,"Please submit user information again",null);
            return responseBean;
        }
    }
}
